<?php

/**
 * Description of UserRegistrationModel
 *
 * @author Animus Inc.
 */

define('DOMROOT', dirname(dirname(__FILE__)));

// imports
require_once DOMROOT.'/classes/abstract/Model.php';
require_once DOMROOT.'/orm/classes/DBDependencyContainer.class.php';

// definition

class UserRegistrationModel {
    
    private $_attributes;
    private $_key_index;
    private $_user_login_details;
    private $_user_profile;
    private $_db;


    public function __construct(){
        $this->_attributes = array();
        $this->_db = new DBDependencyContainer();
        $this->_user_login_details = $this->_db->getRelationalEntity("_user_login_details");
        
    }
    
    public function setAttribute($_key,$_value){
        $this->_attributes[$_key] = $_value;
        array_push($this->_key_index, $_key);
    }
    
    public function setAttributes( $attributes){
    
        $this->_attributes = $attributes;
    }
    public function save(){
        
        $_user_id = $this->_attributes["_user_id"];
        $_salt = $this->_attributes["_salt"];
        $_fname = $this->_attributes["_fname"];
        $_lname = $this->_attributes["_lname"];
        $_email = $this->_attributes["_email"];
        $_pass = $this->_attributes["_pass"];
        $_reg_time = $this->_attributes["_reg_time"];
        $_ver_status = $this->_attributes["_ver_status"];
        $_ver_key = $this->_attributes["_ver_key"];
        $_ver_date = $this->_attributes["_ver_date"];
        
        $this->_user_login_details->bindValue("_user_id", $_user_id);
        $this->_user_login_details->bindValue("_email", $_email);
        $this->_user_login_details->bindValue("_fname", $_fname);
        $this->_user_login_details->bindValue("_lname", $_lname);
        
//        $this->_user_profile->bindValue("_user_id", $_user_id);
//        $this->_user_profile->bindValue("_fname", $_fname);
//        $this->_user_profile->bindValue("_lname", $_lname);
//        $this->_user_profile->bindValue("_email", $_email);
//        $this->_user_profile->bindValue("_reg_time", $_reg_time);
//        $this->_user_profile->bindValue("_ver_status", $_ver_status);
//        $this->_user_profile->bindValue("_ver_date", $_ver_date);
//        $this->_user_profile->bindValue("_ver_key", $_ver_key);
        
        
        
        $_sql_user_login_details = new SQL($this->_user_login_details);
//        $_sql_user_profile = new SQL($this->_user_profile);
        
        $_sql_user_login_details->insert();
//        $_sql_user_profile->insertQuery();
        
        $adapter = $this->_db->getDBDBean()->getAdapterInstance();
        
        $adapter->insert($_sql_user_login_details);
//        $adapter->insert($_sql_user_profile);

                
    }
    
    
}

?>
